#ifndef LINEPROCESSING_H
#define LINEPROCESSING_H

#include <opencv2/opencv.hpp>
#include <QString>
#include <QObject>
#include <QMutex>
#include <QImage>

using namespace cv;


class lineProcessing: public QObject {
Q_OBJECT


public:
    lineProcessing(QString inVideo,QString  outYML);
    bool terminateCheck;
    QImage qimgLineImage;

    unsigned char cutoffB, cutoffR;  //cutoff for peak values
    unsigned char minThresh;     //set a minimum threshold for cutoff
    int lineangle;        // line angle factor
    bool filterOnOff;    // toggle for filtering
    int minConfExport;  //the minimum confidence for export, anything lower will not be exported
    int testLocation;  //location in the video to do a test run
    bool resultsOutput;  // toggle to shut of writing results to the YML file  (false if doing a test frame)


public slots:
    int doIt(); //main processing function
    void terminateProcessing(); //user clicked the terminate button

signals:
    void finished();
    void status(int);
    void lineImage();

private:
    void checkNeighbor(Mat &matLines, Mat &matPeaks, int xloc, int yloc);
    uchar bestLine(Mat &matL,int x, int y);
    void writePoints(Mat matL, int minConfidence, int frameNumber, FileStorage &fs);

    QString inVideoFile;
    QString outYMLFile;



    static QMutex m; //mutex for protecting access to video reader, declared here

};

#endif // LINEPROCESSING_H
